package fr.ifsic.film.client.ui;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.VerticalPanel;

import fr.ifsic.film.client.FilmProject;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;

public abstract class ListeType extends VerticalPanel{
	protected final Button annuler = new Button("Annuler");
	protected final Button effacer = new Button("Effacer");
	protected final Button details = new Button("Details");
	protected final HorizontalPanel horizontalPanel = new HorizontalPanel();
	protected final VerticalPanel verticalPanel = new VerticalPanel();
	protected ListBox listBox = new ListBox();
	protected final Label title;
	
	public ListeType(String title) {
		this.title = new Label(title);
	    add(verticalPanel);
		
		verticalPanel.add(this.title);
		verticalPanel.setCellHorizontalAlignment(this.title, HasHorizontalAlignment.ALIGN_CENTER);
		verticalPanel.add(listBox);
		listBox.setWidth("200px");
		listBox.setVisibleItemCount(10);
		verticalPanel.add(horizontalPanel);
		horizontalPanel.add(annuler);
	    horizontalPanel.add(effacer);
	    horizontalPanel.add(details);
	    
	    annuler.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				annuler();
			}
		});
	    
	    effacer.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				effacer();
			}
		});
	    
	    details.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				details();
			}
		});
	 }
	
	protected void annuler(){
		FilmProject.changePage(FilmProject.accueil);
	}
	
	abstract void effacer();
	abstract void details();
	abstract void refresh();

}
